<?php namespace app\admin\controller;
use app\common\controller\AdminBase;
use app\common\model\Category;
use app\common\model\Article;
use think\Controller;
//文章管理
class Arti extends Controller{
	private $db;
	
	public function _initialize(){
		parent::_initialize();
		$this->db=new Article();
	}
	
	//文章列表
	public function index(){
		if(request()->isPost()){
			
		}else{
			
			return $this->fetch();
		}
		
	}
	
	//添加文章
	public function add(){
		if(request()->isPost()){
				$res=$this->db->addData(input('post.'));
				if($res['valid']){
					$this->success($res['msg'],'arti/index');exit;
					
				}else{
					$this->error($res['msg']);exit;
				}
		}else{
				//获得所以的栏目数据
				$categorys=(new Category)->getAllData();
	//			halt($categorys);
				$this->assign('cate',$categorys);
				//获得所有的标签的数据
				$tag=db('tag')->select();
				$this->assign('tag',$tag);
				return $this->fetch();
		}
		
	}
}
